# Contributor: Leo <thinkabit.ukim@gmail.com>
# Contributor: Diego Queiroz <diego.queiroz@gmail.com>
# Maintainer: Diego Queiroz <diego.queiroz@gmail.com>
pkgname=zbar
pkgver=0.23.1
pkgrel=0
pkgdesc="Port of ZBAR BAR CODE READER"
url="http://zbar.sourceforge.net/"
arch="all"
license="LGPL-2.0-or-later"
depends="py3-gobject3"
makedepends="imagemagick-dev gtk+3.0-dev qt5-qtx11extras-dev lcms2-dev
	automake autoconf libtool xmlto docbook-xsl libxv-dev python3-dev
	gettext-dev gobject-introspection-dev"
subpackages="
	$pkgname-dev
	$pkgname-doc
	lib$pkgname:zbarlibs
	lib${pkgname}qt:qtlibs
	lib${pkgname}gtk:gtklibs
	py3-${pkgname}:py
	"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/mchehab/zbar/archive/$pkgver.tar.gz
	"

prepare() {
	default_prepare
	autoreconf -fi
}

build() {
	LDFLAGS="$LDFLAGS -lintl" \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--disable-video \
		--with-python=python3 \
		--with-gtk=gtk3 \
		--with-gir
	make
}

package() {
	make DESTDIR="$pkgdir" install
	rm -rf "$pkgdir"/usr/lib/*.a
}

zbarlibs() {
	depends=""
	pkgdesc="$pkgdesc (library)"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libzbar.so.* "$subpkgdir"/usr/lib
}

qtlibs() {
	depends=""
	pkgdesc="$pkgdesc (Qt5 library)"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libzbarqt.so.* "$subpkgdir"/usr/lib
}

gtklibs() {
	depends=""
	pkgdesc="$pkgdesc (Gtk+3 library)"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libzbargtk.so.* "$subpkgdir"/usr/lib
}

py() {
	depends=""
	pkgdesc="python3 bindings for ZBar"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/python3* "$subpkgdir"/usr/lib
}

sha512sums="ae7741cf750a10cf53dc11abcd482c3885507153ee37f6e3364ed5ed72184ebb009560b8c40d8090603a551fb681700a962838a59ce77d005d080ee49fbfa54b  zbar-0.23.1.tar.gz"
